package com.aj.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.aj.utils.Contants;

public class LoginActivity extends Activity {
	private EditText username;
	private EditText password;
	private Button login_button;
	private TextView forgetpassword;
	private TextView registeruser;
	public static LoginActivity instance;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_login);
		initView();
	}

	private void initView() {
		instance = this;
		username = (EditText) findViewById(R.id.username);
		password = (EditText) findViewById(R.id.password);
		login_button = (Button) findViewById(R.id.login_button);
		forgetpassword = (TextView) findViewById(R.id.forgetpassword);
		registeruser = (TextView) findViewById(R.id.registeruser);
		ClickEvent clickEvent = new ClickEvent();
		login_button.setOnClickListener(clickEvent);
		forgetpassword.setOnClickListener(clickEvent);
		registeruser.setOnClickListener(clickEvent);
	}

	class ClickEvent implements OnClickListener {
		@Override
		public void onClick(View v) {
			Intent intent = null;
			switch (v.getId()) {
			case R.id.login_button:
				intent = new Intent(Contants.HOMEACTIVITY_ACTION);
				startActivity(intent);
				finish();
				break;
			case R.id.forgetpassword:
				Toast.makeText(LoginActivity.this, "忘记秘密", Toast.LENGTH_LONG)
						.show();
				intent = new Intent(Contants.ENTER_PHONE_ACTION);
				intent.putExtra(Contants.PAGEFLAG_STRING,
						Contants.FORGET_PAGEFLAG_STRING);
				startActivity(intent);
				break;
			case R.id.registeruser:
				Toast.makeText(LoginActivity.this, "注册", Toast.LENGTH_LONG)
						.show();
				intent = new Intent(Contants.ENTER_PHONE_ACTION);
				intent.putExtra(Contants.PAGEFLAG_STRING,
						Contants.REGISTER_PAGEFLAG_STRING);
				startActivity(intent);
				break;
			default:
				break;
			}
		}
	}
}
